package pri.chuang.wl.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import pri.chuang.wl.dao.MessageDao;
import pri.chuang.wl.model.Message;
import pri.chuang.wl.service.MQService;

@Controller
public class DefaultContrller {

	@Autowired
	@Qualifier("mQService")
	private MQService mQService;
	
	@Autowired
	@Qualifier("messageDao")
	private MessageDao messageDao;
	
	@RequestMapping("/")
	public String index(){
		System.out.println("Index");
		return "index";
	}
	
	@RequestMapping("/send/{msg}")
	@ResponseBody
	public String sendMsg(@PathVariable("msg") String msg){
		mQService.send(msg);
		return msg;
	}
	
	@RequestMapping("/savemsg")
	@ResponseBody
	public Message saveMsg(){
		Message message=new Message();
		message.setId(1000);
		message.setContent("Content1111111");
		message.setTitle("Title00000000000000");
		messageDao.insertMsg(message);
		return message;
	}
	
}
